<template>
  <div class="block_main blue-tit">
    <!-- <div class="nytit">首页&gt;通知/督办</div> -->
    <el-row style="padding-top: 10px">
      <el-col :span="24" style="padding:0 5px">
        <el-card>
          <div class="title">
            <em>{{menutitle}}</em>
          </div>
          <!-- 筛选 -->
          <el-form style="padding:20px 20px 0" :inline="true" :model="filter" class="demo-form-inline" size="small">
            
            <el-form-item label="搜索项目名称">
              <el-input v-model="filter.name"></el-input>
              
              <!-- <el-button type="success" @click="AddQuestion">新建诉求</el-button> -->
            </el-form-item>
            <el-button @click="filterFn" type="primary" size="small">查询</el-button>
            <el-button @click="addMenu" type="success" size="small">新增项目</el-button>
            <!-- <span style="float:right;line-height:40px;">累计{{pagetotal}}项</span> -->
          </el-form>

          <el-table border :data="tableData" style="width: 100%" v-loading="loading">
            <el-table-column type="index" width="70" label="序号" fixed></el-table-column>
            <el-table-column prop="name" label="项目名称" :show-overflow-tooltip="true" fixed></el-table-column>

            <el-table-column label="操作" width="150">
              <template slot-scope="scope">
                <el-button @click="edit(scope.row,scope.$index)" type="text" size="mini">编辑</el-button>
                <el-button @click="delList(scope.row,scope.$index)" type="text" size="mini">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
          <!-- 翻页 -->
          <div class="zpage">
            <el-pagination
              @current-change="handleCurrentChange"
              :current-page.sync="currentPage"
              :page-size.sync="pagesize"
              layout="total, prev, pager, next, jumper"
              :total.sync="pagetotal"
            ></el-pagination>
          </div>
          <!-- 翻页 end -->
        </el-card>
      </el-col>
    </el-row>


    <el-dialog
      title="提示"
      :visible.sync="dialogVisible"
      width="30%"
      >
      <span>确定删除吗？</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogSrue">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import actionurl from "@/assets/js/actionurl";
import config from "@/config.js";

export default {
  components: {},
  data() {
    return {
    dialogVisible:false,
    ThisID:'',
    filter:{},
      loading: true,
      menutitle: "二级菜单列表",
      tableData: [],
      currentPage: 1,
      pagesize: 10,
      pagetotal: 10000
    };
  },
  components: {},
  methods: {
    getList() {
      //获取列表信息
      var _this = this;
      actionurl.getListByGroup(
        {
        name:_this.filter.name,
          group: _this.$route.params.id,
          pageOn: _this.currentPage,
          pageNum: 10
        },
        function(re) {
            console.log(re);
          if (re.status == 1) {
            _this.tableData = re.data;
            _this.pagetotal = re.count;
          }
          _this.loading = false;
          // _this.MessageList();
        }
      );
    },
    edit(row) {//编辑
        this.$router.push({path: '/serviceEdit/'+this.$route.params.id+'/'+row.id});

    },
    handleCurrentChange(val) {
      this.currentPage == val;
      this.getList();
    },
    dialogSrue(){//弹窗确定按钮
      this.delListUrlFn();
    },
    delList(row){
      this.ThisID = row.id;
      this.dialogVisible = true;
    },
    delListUrlFn(){//删除
      var _this = this;
      actionurl.WproDel(
        {
          id:_this.ThisID
        },
        function(re) {
          _this.loading = false;
          _this.$message(re.msg);
          _this.dialogVisible = false;
          if (re.status == 1) {
            _this.getList();
          }
          
          // _this.MessageList();
        }
      );
    },
    addMenu(){//新增项目
        this.$router.push({path: '/serviceEdit/'+this.$route.params.id+'/-1'});
    },
    filterFn(){//筛选
      this.getList();
    }
  },
  created() {
    this.getList();
    this.menutitle = this.$route.params.name;
  }
};
</script>

<style lang="scss" scoped>
</style>
